
import router from '../router'
import Vue from 'vue'
const whiteList = ['login']
const RegisterList = ['Register', 'ToRegister', 'NumVerification', 'SucceeRegister']
let currentPage = {}
function resize () {
  const width = document.body.offsetWidth
  const height = document.body.offsetHeight
  if (!whiteList.includes(currentPage.name)) {
    document.getElementsByTagName('html')[0].style.fontSize = width / 10 + 'px'
    if (width > 1920) {
      document.getElementsByTagName('html')[0].style.fontSize = '220px'
    }
    if (RegisterList.includes(currentPage.name)) {
      document.getElementsByTagName('html')[0].style.fontSize = width / 2 + 'px'
    }
  } else {
    Vue.nextTick(() => {
      resizeLogin(width, height)
    })
  }
}
// 登录页适配
function resizeLogin (width, height) {
  if (document.getElementsByClassName('form-container')[0]) {
    const formHegith = document.getElementsByClassName('form-container')[0].offsetHeight
    if (formHegith >= height) {
      const scale = formHegith / height * 1.2
      document.getElementsByTagName('html')[0].style.fontSize = width / 10 / scale + 'px'
    }
  }
}
window.onload = () => {
  resize()
}
window.onresize = (e) => {
  // alert(123)
  resize()
}
router.afterEach(current => {
  currentPage = current
  resize()
})
